.widget-content {
    margin-bottom: var(--markdown-interelement-space-px);
}

.widget-choices {
    & ul {
        padding: 3px;
    }

    & li {
        padding: 2px;
        list-style: none;
    }

    & button {
        font-weight: 700;
        color: hsl(240deg 100% 50%);
    }

    .widget-choices-heading {
        font-weight: 600;
    }
}

.todo-widget {
    .todo-task-list-title-bar {
        flex: 1 1 auto;
        display: flex;
        /* Ensure controls remain visible on narrower screens. */
        flex-flow: row wrap;
        gap: 5px;
        margin-bottom: var(--markdown-interelement-space-px);
    }

    .add-task-bar {
        display: flex;
        /* Ensure controls remain visible on narrower screens. */
        flex-flow: row wrap;
        gap: 5px;
    }

    /* For the box-shadow to be visible on the left */
    .add-task,
    .add-desc {
        font-weight: 400;
    }

    & label.checkbox {
        display: flex; /* Arrange that a multi-line description line wraps properly. */
        /* Keep checkboxes vertically aligned, including with multi-line tasks. */
        align-items: baseline;
        /* Reset things from .new-style */
        gap: 5px;
        position: static;
        min-height: 0;

        & input[type="checkbox"] {
            ~ .custom-checkbox {
                position: static;
                margin-right: 0;

                height: 12px;
                width: 12px;
                border: 2px solid hsl(156deg 28% 70%);

                border-radius: 4px;
                filter: brightness(1);

                cursor: pointer;
            }

            &:checked ~ .custom-checkbox {
                background-image: url("../images/checkbox-white.svg");
                background-size: 75%;
                background-position: 50% 50%;
                background-repeat: no-repeat;
                background-color: hsl(156deg 41% 40%);
                border: 2px solid hsl(156deg 41% 40%);
            }

            &:disabled ~ .custom-checkbox {
                opacity: 0.5;
                cursor: not-allowed;
            }

            &:hover ~ .custom-checkbox {
                border-color: hsl(156deg 30% 50%);
            }

            &:focus ~ .custom-checkbox {
                outline-color: hsl(0deg 0% 100% / 0%);
            }
        }
    }
}

.todo-widget,
.poll-widget {
    & h4 {
        font-size: 18px;
        font-weight: 600;
    }

    & li {
        display: flex;
        gap: 5px;
        align-items: baseline;
        list-style: none;
        margin: 0 0 5px;
    }

    & ul {
        margin: 0 0 5px;
        padding: 0;
    }

    & input[type="text"] {
        /* Reset from zulip.css */
        height: unset;

        border: 1px solid hsl(0deg 0% 80%);
        box-shadow: inset 0 1px 1px hsl(0deg 0% 0% / 7.5%);
        transition:
            border linear 0.2s,
            box-shadow linear 0.2s;
        border-radius: 4px;
        color: hsl(0deg 0% 33%);

        &:focus {
            border-color: hsl(206deg 80% 62% / 80%);
            outline: 0;
            box-shadow: none;
            background-color: var(--color-background-widget-input);
        }
    }
}

.poll-widget {
    .poll-option-bar {
        display: flex;
        /* Ensure controls remain visible on narrower screens. */
        flex-flow: row wrap;
        gap: 5px;
    }

    .poll-option {
        font-weight: 400;
    }

    & span.poll-option {
        font-weight: 600;
        /* Start with max-content, but allow options
           to shrink, so that voting names wrap comfortably. */
        flex: 0 1 max-content;
    }

    .poll-vote {
        color: hsl(156deg 41% 40%);
        border-color: hsl(156deg 28% 70%);
        border-style: solid;
        font-weight: 600;
        border-radius: 3px;
        min-width: 25px;
        height: 25px;
        font-size: 13px;
        background-color: hsl(0deg 0% 100%);

        &:hover {
            border-color: hsl(156deg 30% 50%);
        }

        &:focus {
            outline: 0;
            background-color: hsl(156deg 41% 90%);
        }
    }

    .poll-names {
        color: hsl(0deg 0% 45%);
        /* Aim for 50% of the flexbox for voting names,
           but also shrink modestly (.5) adjacent a long
           option. */
        flex: 1 0.5 50%;
    }
}

button {
    &.task {
        height: 20px;
        width: 20px;
        background-color: transparent;
        border-color: hsl(156deg 28% 70%);
        margin-right: 4px;
        border-radius: 3px;

        &:hover {
            border: 1px solid hsl(194deg 60% 40%);
        }
    }

    &.add-task,
    &.poll-option {
        color: hsl(156deg 41% 40%);
        border: 1px solid hsl(156deg 28% 70%);
        width: max-content;
        flex: 0 0 auto;
        border-radius: 3px;
        background-color: hsl(0deg 0% 100%);
        padding: 4px;
        padding-left: 14px;
        padding-right: 14px;
        transition: all 0.2s ease;

        &:hover,
        &:focus {
            outline: 0;
            border-color: hsl(156deg 30% 50%);
        }

        &:active {
            border-color: hsl(156deg 30% 40%);
            color: hsl(156deg 44% 43%);
            background-color: hsl(154deg 33% 96%);
        }
    }
}

input {
    &.add-task,
    &.add-desc,
    &.poll-option,
    &.poll-question,
    &.todo-task-list-title {
        flex: 1 0 auto;
        padding: 4px 6px;
    }
}

.widget-error {
    color: hsl(1deg 45% 50%);
    font-size: 12px;
}

.poll-question-check,
.poll-question-remove,
.todo-task-list-title-check,
.todo-task-list-title-remove {
    align-self: stretch;
    /* TODO: Re-express the 30.5px value here
       as part of information density work. */
    flex: 0 0 30.5px;
    min-height: 30.5px;
    border-radius: 3px;
    border: 1px solid hsl(0deg 0% 80%);
    background-color: hsl(0deg 0% 100%);

    &:hover {
        border-color: hsl(0deg 0% 60%);
    }
}

.poll-edit-question,
.todo-edit-task-list-title {
    opacity: 0.4;

    &:hover {
        opacity: 1;
    }
}

.poll-question-bar {
    flex: 1 1 auto;
    display: flex;
    /* Ensure controls remain visible on narrower screens. */
    flex-flow: row wrap;
    gap: 5px;
    margin-bottom: var(--markdown-interelement-space-px);
}

.poll-widget-header-area,
.todo-widget-header-area {
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.current-user-vote {
    background-color: hsl(156deg 10% 90% / 90%);
}
